﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Medianamik.UI.Mediasend.Logic
{
    /// <summary>
    /// Retourne les soulistes d'une listes.
    /// Les soulistes sous en fait que des filtres sous la liste principales.
    /// </summary>
    public class MediasendSubList
    {
        #region " MEMBERS "
            /// <summary>
            /// La liste attaché à cette sous liste
            /// </summary>
            public MediasendList Parent { get; private set; }

            public int ID { get; private set; }

            public string Name { get; private set; }

            public int ContactCount { get; private set; }
        #endregion

        #region " Ctor "
            public MediasendSubList()
            { }

            public MediasendSubList(MediasendList parent, int id, string name, int contactCount)
            {
                ID = id;
                Parent = parent;
                Name = name;
                ContactCount = contactCount;
            }
        #endregion

        #region " HELPERS "
            internal static MediasendSubList MakeSublist(MediasendList parent, Dictionary<string, object> record)
            {
                var sl = new MediasendSubList
                             {
                                 Parent = parent,
                                 ID = int.Parse(record["id"].ToString()),
                                 Name = record["name"].ToString(),
                                 ContactCount = int.Parse(record["count"].ToString())
                             };

                return sl;
            }
   
        #endregion
    }
}
